using System;
using System.Text.RegularExpressions;

namespace DynamicConfigurationManager.ConfigMapAttributes
{
    /// <summary>
    /// ExecutablePathRegEx compares the attribute value to the fully qualified path of the AppDomain's current base directory.
    /// </summary>
    internal class ExecutablePathRegEx : IConfigMapAttribute
    {
        public bool Execute( string configMapAttribute )
        {
            var baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
            LogHelper.Append( "ExecutablePathRegEx: matching to {0}", baseDirectory );
            var re = new Regex( configMapAttribute, RegexOptions.IgnoreCase );
            return re.IsMatch( baseDirectory );
        }
    }
}